//自动登录
if (sessionStorage.getItem('email') && sessionStorage.getItem('password')){
    $.ajax({
        type: 'POST',
        dataType: 'json',
        url: '/loginstate',
        data: {
            email: sessionStorage.getItem('email'),
            password: sessionStorage.getItem('password'),
        },
        success: function (result) {
            if (result == '200') {
                window.location.href = '/admin'
            }
        }
    })
}
//手动登录
function loginstate(){
    $.ajax({
        type:'POST',
        dataType:'json',
        url:'/loginstate',
        data:{
            email: $('#email').val(),
            password: md5(md5($('#password').val())),
        },
        success: function (result){
            if(result == '200'){
                sessionStorage.setItem('email', $('#email').val());
                sessionStorage.setItem('password', md5(md5($('#password').val())));
                window.location.href = '/admin'
            } else {
                alert('邮箱或密码错误');
                $('#password').val('');
            }
        }
    })
}